# coding=utf8
import csv
import datetime
import json
import random
import time
from idcard import gennerator, random_name
from card_bin import getCardNumber, gen_card_num_fixed, card_bin_list
from selenium import webdriver
from selenium.webdriver.common.by import By
from loguru import logger
import requests
from toollib import autodriver



def logging(funcDesc=None):  # 用于装饰的函数名
    def outwrapper(func):  # 接收 用于调用的函数名
        def wrapper(*args, **kwargs):  # 接收 传递到调用函数的参数
            logger.info(f"{funcDesc},调用:{func.__name__}()")
            logger.info(f"请求参数:{args} {kwargs}")
            returnData = func(*args, **kwargs)  # 调用被装饰的函数
            logger.debug(f"{'返回数据'}:{returnData}")
            return returnData

        return wrapper

    return outwrapper


class CreatUser:
    def __init__(self, url=None):
        """自动化oa登陆获取 获取cookie并保存"""
        cookieTime = ''
        try:
            with open("../cookie.json", "r") as data:  # 获取保存的cookie
                cookieData = json.loads(data.read())
                cookieTime = cookieData["time"]
                self.cookie = cookieData["cookie"]
                if str(datetime.date.today()) != cookieTime:  # 判断 是否 属于今天的cookie
                    logger.debug("cookie已过期，重新获取cookie")
                    self.auto_get_cookies()

        except:
            logger.debug("获取cookie.txt信息失败,重新获取cookie")
            self.auto_get_cookies()

    @logger.catch
    def auto_get_cookies(self):
        options = webdriver.ChromeOptions()
        options.add_argument('headless')
        try:
            browser = webdriver.Chrome(executable_path=autodriver.chromedriver(), options=options)
        except:
            raise Exception("chromedriver驱动不存在或版本不一致，请使用与Chrome浏览器版本一致的chromedriver驱动")
        browser.implicitly_wait(5)
        browser.get("https://xuat.wxp.woa.com/assistant/caseInputManagement")
        browser.find_element(By.ID, "btn_smartlogin").click()  # oa登录
        time.sleep(1)

        cookies = browser.get_cookies()
        cookie_list = [(i["name"] + "=" + i["value"]) for i in cookies]
        self.cookie = ";".join(cookie_list)
        with open("../cookie.json", "w") as data:
            data.write(json.dumps({"time": str(datetime.date.today()), "cookie": self.cookie}))
        logger.debug("已成功获取cookie，并保存")
        browser.quit()

    @logger.catch
    @logging("往用户系统发送post请求")
    def post_accpunt(self, url, data):
        """往用户系统发送请求"""
        headers = {
            "API-TOKEN": "ce29b4f23a4630a8bc23700c01728c46",
            "Cookie": self.cookie,
            "Host": "testaccount.wxp.woa.com",
            "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.110 Safari/537.36 Edg/96.0.1054.62",
        }
        re = requests.post(url, data=data, headers=headers)
        return re.json()

    @logger.catch
    @logging("往用户系统发送get请求")
    def get_accpunt(self, url):
        """往用户系统发送请求"""
        headers = {
            "API-TOKEN": "ce29b4f23a4630a8bc23700c01728c46",
            "Cookie": self.cookie,
            "Host": "testaccount.wxp.woa.com",
            "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.110 Safari/537.36 Edg/96.0.1054.62",
        }
        logger.debug(f"请求url：{url}")
        re = requests.get(url, headers=headers)
        logger.debug(f"请求结果：{re}")
        return re.json()

    @logger.catch
    @logging("往uat系统发送请求")
    def get_uat(self, url):
        """往uat系统发送请求"""
        headers = {
            'Content-Type': 'application/json',
            "Cookie": self.cookie,
            "Host": "xuat.wxp.woa.com",
            "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.110 Safari/537.36 Edg/96.0.1054.62",
        }
        logger.debug(f"请求url：{url}")
        re = requests.get(url, headers=headers)
        logger.debug(f"请求结果：{re}")
        return re.json()

    @logger.catch
    @logging("往uat系统发送请求")
    def post_uat(self, url, data):
        """往uat系统发送请求"""
        headers = {
            'Content-Type': 'application/json',
            "Cookie": self.cookie,
            "Host": "xuat.wxp.woa.com",
            "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.110 Safari/537.36 Edg/96.0.1054.62",
        }
        re = requests.post(url, data=json.dumps(data), headers=headers)
        return re.json()

    @logger.catch
    @logging("往mmtools系统发送get请求")
    def mmtools_get(self, url):
        """往mmtools系统发送get请求"""
        headers = {
            "Cookie": self.cookie,
            "Host": "wxunitest.oa.com",
            "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.110 Safari/537.36 Edg/96.0.1054.62",
        }
        re = requests.get(url, headers=headers)
        return re.text

    @logger.catch
    @logging("发送可测性api请求")
    def post_xapitest(self, url, data):
        """发送可测性api请求"""
        headers = {
            'Content-Type': 'application/json',
            'token': 'fcc68345-ff80-4612-97cd-109ebaa862c3',
            'UAT-MultiSet': '0',
        }
        re = requests.post(url, data=json.dumps(data), headers=headers)
        return re.json()

    @logger.catch
    @logging("设置九要素之一(职业)")

    @logger.catch
    @logging("商户号添加 优惠批次")
    def post_api_modify_include_mch(self, mchid):
        """商户号添加 优惠批次"""
        # stock_id批次ID：https://iwiki.woa.com/pages/viewpage.action?pageId=583627880
        url = 'http://xapitest.wxp.woa.com/xautotest/busiapi/api/api_modify_include_mch'
        stock_id_list = [16288216, 16727710, 16758408, 16758409, 16758410, 16758291, 16758292, 16758293, 16648001,
                         16648005, 16599783, 16783784, 16783786, 16673025, 16672970, 16673032, 16672824, 16673033,
                         16709731, 16510865, 16511004, 16511025, 16510909, 16510920, 16511049, 15952573, 15952574,
                         16898981, 16898986, ]
        if isinstance(mchid,list):
            mchid_add_set = mchid
        else:
            mchid_add_set = [mchid]
        for stock_id in stock_id_list:
            data = {"partner_id": 99999184, "stock_id": stock_id, "mchid_add_set": mchid_add_set, "mchid_del_set": []}
            self.post_xapitest(url, data)

    def get_id_card_register_count(self, age=None):
        """
        获取一个仅使用过一个的身份证号码
        :age: 默认为18，age大于等于18时，生成年龄大于18岁，当18小于则获取年龄小于18岁
        """
        url = "http://testaccount.wxp.woa.com/useraccount/account/get_id_card_register_count"
        while True:
            userId = gennerator(age)
            data = {"cardid": userId, "t": int(format(int(time.time() * 1000)))}
            re = self.post_accpunt(url, data)
            logger.info(f"{userId}使用过{re['data']['bind_num']}次")
            if re["data"]["bind_num"] == 0:
                logger.debug(f"{userId}为未使用过的身份证号")
                return userId
            time.sleep(1)

    def gen_card_num_fixed(self, start_with, total_num, uin):
        """
        生成随机 银行卡号
        :param start_with:
        :param total_num:
        :param uin:
        :return:
        """
        result = start_with + str(uin)[1:]
        # 补齐位数
        if len(result) < total_num - 1:
            result += (total_num - 1 -len(result)) * '0'
        # 计算前N-1位的校验和
        s = 0
        card_num_length = len(result)
        for _ in range(2, card_num_length + 2):
            t = int(result[card_num_length - _ + 1])
            if _ % 2 == 0:
                t *= 2
                s += t if t < 10 else t % 10 + t // 10
            else:
                s += t
        # 最后一位当做是校验位，用来补齐到能够整除10
        t = 10 - s % 10
        result += str(0 if t == 10 else t)
        logger.debug('uin: %s, gen bankcard result: %s', uin, result)
        return result


class Operation(CreatUser):

    # 获取该用户组"构造中"的账号,并保存到csv中
    @logger.catch
    @logging('获取该用户组"构造中"的账号,并保存到csv中')
    def get_userGroup(self, userGroupId, total=10):
        url = "http://xuat.wxp.woa.com/apis/v1/featurebaseline/findUserGroupAccountList"
        data = {"pageSize": 99999, "pageNum": 1, "userGroupId": userGroupId}
        re = self.post_uat(url, data)
        uinList = self.get_csv()
        userDataList = []
        with open("tapd.csv", "a+", newline="", encoding="utf8") as csvFile:
            csvFileWriter = csv.writer(csvFile)
            for item in re["data"]["userAccountList"]:
                url = f'http://xuat.wxp.woa.com/assistant/userAccountGroupManagement/userAccountDetail/4800000/{item["userId"]}'
                userData = [item["userGroupId"], item["userUin"], item["userName"], item["userAccId"], url]
                if item["stateId"] == 25 and not item["userAccId"] in json.dumps(uinList):   # 25 构造中
                # if item["stateId"] == 26 and not item["userAccId"] in json.dumps(uinList):   # 26 生效
                    userDataList.append(userData)
                    csvFileWriter.writerow(userData)
                if len(userDataList) == total:
                    break
        return userDataList

    @logger.catch
    @logging('获取商户组里的商户号')
    def get_mchGroupId(self, mchGroupId, total=100):
        url = "https://xuat.wxp.woa.com/apis/v1/featurebaseline/findMchGroupAccountList"
        data = {"pageSize": total, "pageNum": 1, "mchGroupId": mchGroupId}
        re = self.post_uat(url, data)
        return re

    @logger.catch
    @logging('获取商户号')
    def get_mchAutoId(self, mchAutoId):
        url = f"https://xuat.wxp.woa.com/apis/v1/featurebaseline/getMchAutoId?mchAutoId={mchAutoId}"
        re = self.get_uat(url)
        return re

    @logger.catch
    @logging('清除所有数据')
    def clear_userdata(self):
        with open("tapd.csv", "w+", newline="", encoding="utf8"):
            pass

    # 获取保存的 在csv中的 所有uin
    @logger.catch
    @logging("获取保存的在csv中的所有uin")
    def get_csv(self):
        uinList = []
        with open("tapd.csv") as csvfile:
            csv_reader = csv.reader(csvfile)
            for item in csv_reader:
                userData = {"userGroupId": item[0], "userUin": item[1], "userName": item[2], "userAccId": item[3], "url": item[4]}
                if len(item) > 1 and not userData in uinList:
                    uinList.append(userData)
        return uinList


    # chrome自动化创建一个 "完整注册+身份证实名" 的账号
    @logger.catch
    @logging('chrome自动化创建一个 "完整注册+身份证实名" 的账号')
    def chrome_uin(self, uin_list, age=None):
        uin_list = uin_list if type(uin_list) == list else [uin_list]
        browser = webdriver.Chrome(executable_path="../../chromedriver")
        browser.implicitly_wait(5)
        browser.get("http://testaccount.wxp.woa.com/newapplyuser/index")
        browser.find_element(By.ID, "btn_smartlogin").click()  # oa登录
        browser.find_elements(By.CSS_SELECTOR, ".el-button.el-button--primary")[
            -1
        ].click()

        for uin in uin_list:
            browser.get("http://testaccount.wxp.woa.com/newapplyuser/index")
            browser.find_elements(By.CSS_SELECTOR, ".el-radio__label")[3].click()
            browser.find_element(
                By.XPATH, "//input[@class='el-input__inner']"
            ).send_keys(str(uin))
            browser.find_elements(By.CSS_SELECTOR, ".el-radio__label")[3].click()
            try:
                # 兼容 账号是否被重新注册的情况
                browser.find_element(
                    By.XPATH,
                    '//button[@class="el-button el-button--default el-button--small el-button--primary "]',
                ).click()
            except:
                browser.find_element(
                    By.XPATH, '//button[@class="el-button el-button--primary"]'
                ).click()

            browser.find_element(
                By.XPATH, "//span[contains(text(),'完整注册+身份证实名')]"
            ).click()
            browser.find_element(
                By.XPATH, "//input[contains(@placeholder,'请输入6位数字密码')]"
            ).send_keys("135790")

            input_inner = browser.find_element(
                By.XPATH, "//input[contains(@placeholder,'请输入身份证号, 18位')]"
            )
            input_inner.clear()
            input_inner.send_keys(str(self.get_id_card_register_count(age)))
            browser.find_element(
                By.XPATH, "//label[contains(text(),'支付密码')]"
            ).click()  # 检验身份证号是否0次
            time.sleep(2)
            browser.find_element(By.XPATH, "//span[contains(text(),'提交造号申请')]").click()
            time.sleep(2)

        time.sleep(5)
        browser.quit()

    #  创建一个 "简化注册用户" 的账号
    @logger.catch
    @logging('创建一个 "简化注册用户" 的账号')
    def simplify(self, uin):
        logger.info(f'{uin} 创建一个 "简化注册用户" 的账号')
        fparam = {
            "FWechatUin": int(uin),
            "FTpaCountry": ["1"],
        }
        url = "http://testaccount.wxp.woa.com/useraccount/applyment/"
        data = {
            "operate": "add",
            "FAccountType": 2,
            "FUseScence": 5,
            "FParam": json.dumps(fparam),
            "t": str(format(int(time.time() * 1000))),
        }
        re = self.post_accpunt(url, data)
        return re

    #  创建一个 "完整注册未实名" 的账号
    @logger.catch
    @logging('创建一个 "完整注册未实名" 的账号')
    def norealname(self, uin, age=18):
        logger.info(f'{uin} 创建一个 "完整注册未实名" 的账号')
        fparam = {
            "FWechatUin": int(uin),
            "FTpaCountry": ["1"],
            "FPayPasswd": "135790",
            "FRealName": 'name',
            "FIdentityCardId": self.get_id_card_register_count(age),
        }
        url = "http://testaccount.wxp.woa.com/useraccount/applyment/"
        data = {
            "operate": "add",
            "FAccountType": 3,
            "FUseScence": 5,
            "FParam": json.dumps(fparam).replace('name', random_name()),
            "t": str(format(int(time.time() * 1000))),
        }
        re = self.post_accpunt(url, data)
        return re

    #  创建一个 "纯外卡用户" 的账号
    @logger.catch
    @logging('创建一个 "纯外卡用户" 的账号')
    def uservisa(self, uin):
        logger.info(f'{uin} 创建一个 "纯外卡用户" 的账号')
        fparam = {
            "FWechatUin": int(uin),
            "FTpaCountry": ["1"],
            "FPayPasswd": "135790",
            "FFirstName": "pay",
            "FLastName": "test",
            "FPhoneNumber": '18' + str(random.randint(100000000,999999999)),
            "FBankCardId": "4929034537861246",
            "FValidThru": "2612",
            "FBankType": "MASTERCARD_CREDIT",
        }
        url = "http://testaccount.wxp.woa.com/useraccount/applyment/"
        data = {
            "operate": "add",
            "FAccountType": 11,
            "FUseScence": 5,
            "FParam": json.dumps(fparam),
            "t": str(format(int(time.time() * 1000))),
        }
        re = self.post_accpunt(url, data)
        return re

    #  创建一个 "完整注册+身份证实名" 的账号
    @logger.catch
    @logging('创建一个 "完整注册+身份证实名" 的账')
    def applyment(self, uin, age=None):
        logger.info(f'{uin} 创建一个 "完整注册+身份证实名" 的账号')
        fparam = {
            "FPayPasswd": "135790",
            "FRealName": 'name',
            "FIdentityCardId": self.get_id_card_register_count(age),
            "FWechatUin": int(uin),
            "FTpaCountry": ["1"],
        }
        url = "http://testaccount.wxp.woa.com/useraccount/applyment/"
        data = {
            "operate": "add",
            "FAccountType": 4,
            "FUseScence": 5,
            "FParam": json.dumps(fparam).replace('name', random_name()),
            "t": str(format(int(time.time() * 1000))),
        }
        re = self.post_accpunt(url, data)
        return re

    # 创建一个 "二类实名+平安储蓄卡+招商信用卡" 的账号
    @logger.catch
    @logging('创建一个 "二类实名+平安储蓄卡+招商信用卡" 的账号')
    def applyment_pro(self, uin, age=None):
        logger.info(f'{uin} 创建一个 "二类实名+平安储蓄卡+招商信用卡" 的账号')
        fparam = {
            "FPayPasswd": "135790",
            "FRealName": 'name',
            "FIdentityCardId": self.get_id_card_register_count(age),
            "FBankCardInfo": [
                getCardNumber("平安", "储蓄"),
                getCardNumber("招商", "信用"),
            ],
            "FWechatUin": uin,
            "FTpaCountry": ["1"],
        }

        url = "http://testaccount.wxp.woa.com/useraccount/applyment/"
        data = {
            "operate": "add",
            "FAccountType": 9,
            "FUseScence": 5,
            "FParam": json.dumps(fparam).replace('name', random_name()),
            "t": int(format(int(time.time() * 1000))),
        }
        re = self.post_accpunt(url, data)
        return re

    # 创建一个 "三类实名+平安储蓄卡+招商信用卡+浦发储蓄卡+中国信用卡" 的账号
    @logger.catch
    @logging('创建一个 "三类实名+平安储蓄卡+招商信用卡+浦发储蓄卡+中国信用卡" 的账号')
    def applyment_3(self, uin, age=None):
        logger.info(f'{uin} 创建一个 "三类实名+平安储蓄卡+招商信用卡+浦发储蓄卡+中国信用卡" 的账号')
        fparam = {
            "FPayPasswd": "135790",
            "FRealName": 'name',
            "FIdentityCardId": self.get_id_card_register_count(age),
            "FBankCardInfo": [
                getCardNumber("平安", "储蓄"),
                getCardNumber("招商", "信用"),
                getCardNumber("浦发", "储蓄"),
                getCardNumber("中国", "信用"),
            ],
            "FWechatUin": uin,
            "FTpaCountry": ["1"],
        }

        url = "http://testaccount.wxp.woa.com/useraccount/applyment/"
        data = {
            "operate": "add",
            "FAccountType": 10,
            "FUseScence": 5,
            "FParam": json.dumps(fparam).replace('name', random_name()),
            "t": int(format(int(time.time() * 1000))),
        }
        re = self.post_accpunt(url, data)
        return re

    # 绑定一张国内银行卡
    @logger.catch
    @logging("绑定一张国内银行卡")
    def bind_card(self, uin, bankName, cardType):
        logger.info(f"{uin} 绑定一张国内银行卡")
        """
        :param uin: 账户uin
        :param bankName: 银行名称，如：招商银行，平安银行
        :param cardType: 卡片类型，如：信用卡，储蓄卡
        :return:
        """
        url = "http://testaccount.wxp.woa.com/useraccount/tool/bind_card"
        bankData = getCardNumber(bankName, cardType)
        data = {
            "FToolID": 2,
            "FWechatUin": uin,
            "password": 135790,
            "FBankType": bankData["FBankType"],
            "FBankPhone": bankData["FBankPhone"],
            "FBankCardId": bankData["FBankCardId"],
            "FBankCardCVVCode": bankData["FBankCardCVVCode"],
            "FBankCardValidTime": bankData["FBankCardValidTime"],
            "t": int(format(int(time.time() * 1000))),
        }
        self.post_accpunt(url, data)
        return self.get_tool_op_log(uin=uin, FToolID=2)


    # 账户充值零钱
    @logger.catch
    @logging("账户充值零钱")
    def account_recharge(self, uin, money):
        logger.info(f"{uin} 账户充值零钱")
        """
        :param uin: 账号uin
        :param money: 充值金额，单位：元
        :return:    充值后的余额
        """
        url = "http://testaccount.wxp.woa.com/useraccount/tool/account_recharge"
        data = {
            "FToolID": 1,
            "FWechatUin": uin,
            "money": money * 100,
            "t": int(format(int(time.time() * 1000))),
        }
        self.post_accpunt(url, data)
        return self.get_tool_op_log(uin=uin, FToolID=1)


    # "开通分付"
    @logger.catch
    @logging("开通分付")
    def open_or_close_credict(self, uin):
        logger.info(f"{uin} 开通分付")
        url = "http://testaccount.wxp.woa.com/useraccount/tool/open_or_close_credict"
        data = {
            "FToolID": 26,
            "uin": uin,
            "op_type": 0,
            "t": int(format(int(time.time() * 1000))),
        }
        self.post_accpunt(url, data)
        return self.get_tool_op_log(uin=uin, FToolID=26)

    @logger.catch
    @logging("设置九要素之一(职业)")
    def post_api_modifying_userinfo(self, uin):
        """设置九要素之一(职业)"""
        url = 'http://testaccount.wxp.woa.com/useraccount/tool/modify_extend_info'
        data = {
            "FToolID": 1050,
            "FWechatUin": uin,
            "op_type": 3,
            "value": '其他',
            "t": int(format(int(time.time() * 1000))),
        }
        self.post_accpunt(url, data)
        return self.get_tool_op_log(uin=uin, FToolID=1050)

    # "开通零钱通1.5"
    @logger.catch
    @logging("开通零钱通1.5")
    def open_lqt_15(self, uin):
        logger.info(f"{uin} 查询是否已开通零钱通")
        url = "http://testaccount.wxp.woa.com/useraccount/tool/query_lqt_state"
        data = {
            "FToolID": 1010,
            "FWechatUin": uin,
            "t": int(format(int(time.time() * 1000))),
        }
        re = self.post_accpunt(url, data)
        if re['data']['body']['lqt_flag'] == 1:
            return {'FToolName': '零钱通1.5', 'FOpStatus': '已开通'}
        elif re['data']['body']['lqt_flag'] == 2:
            return {'FToolName': '零钱通2.0', 'FOpStatus': '已开通'}

        logger.info(f"{uin} 开通零钱通1.5")
        url = "http://testaccount.wxp.woa.com/useraccount/tool/open_lqt_15"
        data = {
            "FToolID": 15,
            "FWechatUin": uin,
            "t": int(format(int(time.time() * 1000))),
        }
        self.post_accpunt(url, data)
        return self.get_tool_op_log(uin=uin, FToolID=15)

    @logger.catch
    @logging("开通零钱通2.0")
    def open_lqt_20(self, uin, accid):
        logger.info(f"{uin} 查询是否已开通零钱通")
        url = "http://testaccount.wxp.woa.com/useraccount/tool/query_lqt_state"
        data = {
            "FToolID": 1010,
            "FWechatUin": uin,
            "t": int(format(int(time.time() * 1000))),
        }
        re = self.post_accpunt(url, data)
        if re['data']['body']['lqt_flag'] == 1:
            return {'FToolName': '零钱通1.5', 'FOpStatus': '已开通'}
        elif re['data']['body']['lqt_flag'] == 2:
            return {'FToolName': '零钱通2.0', 'FOpStatus': '已开通'}

        bankDataList = self.query_wechat_pay_bindcard_info(uin)
        if len(bankDataList) == 0:
            return {'FToolName': '零钱通2.0', 'FOpStatus': '开通失败-未绑定储蓄卡'}
        else:
            serialno = 0
            for bankData in bankDataList:
                for item in card_bin_list:
                    if str(bankData['bank_type']) == item['bank_type'] and item['card_type'] == '1':
                        serialno = bankData['Fbind_serialno']
                        break
                if serialno:
                    break
            else:
                return {'FToolName': '零钱通2.0', 'FOpStatus': '开通失败-未绑定储蓄卡'}

        self.post_api_modifying_userinfo(uin)   # 修改九要素
        logger.info(f"{uin} 开通零钱通2.0")
        url = "http://testaccount.wxp.woa.com/useraccount/tool/open_lqt_20"
        data = {
            "FToolID": 17,
            "FWechatUin": uin,
            "FBindSerialno": serialno,
            "t": int(format(int(time.time() * 1000))),
        }
        self.post_accpunt(url, data)
        return self.get_tool_op_log(uin=uin, FToolID=17)

    # "充值零钱通,单位元"
    @logger.catch
    @logging("充值零钱通,单位元")
    def lqt_buy(self, uin, fee_amount=3000):
        logger.info(f"{uin} 充值零钱通")
        url = "http://testaccount.wxp.woa.com/useraccount/tool/lqt_buy"
        data = {
            "FToolID": 1016,
            "FWechatUin": uin,
            "fee_amount": fee_amount * 100,
            "pay_type": 0,
            "passwd": 135790,
            "t": int(format(int(time.time() * 1000))),
        }
        self.post_accpunt(url, data)
        return self.get_tool_op_log(uin=uin, FToolID=1016)

    # "绑定一张外卡"
    @logger.catch
    @logging("绑定一张外卡")
    def bind_waika(self, uin):
        logger.info(f"{uin} 绑定一张外卡")
        url = "http://testaccount.wxp.woa.com/useraccount/tool/bind_waika"
        data = {
            "FToolID": 27,
            "uin": uin,
            "passwd": 135790,
            "bank_card_id": gen_card_num_fixed("453933", 16, str(random.randint(10 ** 9, 9 * 10 ** 9))),
            # "bank_card_id": 4929034537861246,
            "bank_type": "MASTERCARD_CREDIT",
            "t": int(format(int(time.time() * 1000))),
        }
        self.post_accpunt(url, data)
        return self.get_tool_op_log(uin=uin, FToolID=27)

    #  开通 零钱提额
    @logger.catch
    @logging('开通 零钱提额')
    def yu_e_ti_e(self, uin, accid):
        logger.info(f'开通 零钱提额{uin} ')
        self.post_api_modifying_userinfo(uin)   # 修改九要素
        bankDataList = self.query_wechat_pay_bindcard_info(uin)    # 查询绑卡信息 获取绑卡序列号
        if len(bankDataList) == 0:
            logger.error(f'uin:{uin} 未绑卡,无法开通零钱提额')
            return
        serialno = bankDataList[0]['Fbind_serialno']

        url = "http://testaccount.wxp.woa.com/useraccount/tool/yu_e_ti_e"
        data = {
            "FToolID": 18,
            "FWechatUin": uin,
            "FBindSerialno": serialno,
            "t": str(format(int(time.time() * 1000))),
        }
        self.post_accpunt(url, data)
        return self.get_tool_op_log(uin=uin, FToolID=18)

    # 开通 银行通
    @logger.catch
    @logging('开通 银行通')
    def open_yht(self, uin):
        logger.info(f'开通 银行通{uin}')
        url = "http://testaccount.wxp.woa.com/useraccount/tool/open_yht"
        data = {
            "FToolID": 1049,
            "FWechatUin": uin,
            "password": 135790,
            "mobile_no": "130" + str(random.randint(10 ** 7, 9 * 10 ** 7)),
            "t": str(format(int(time.time() * 1000))),
        }
        self.post_accpunt(url, data)
        return self.get_tool_op_log(uin=uin, FToolID=1049)


    # 添加 分付白名单
    @logger.catch
    @logging('添加 分付白名单')
    def set_creditinfo(self, uin):
        logger.info(f'添加 分付白名单{uin}')
        url = "http://testaccount.wxp.woa.com/useraccount/tool/set_creditinfo"
        data = {
            "FToolID": 1026,
            "FWechatUin": uin,
            "op_type": 1,
            "credit_limit": 1000000,
            "credit_rate": 3,
            "t": str(format(int(time.time() * 1000))),
        }
        self.post_accpunt(url, data)
        return self.get_tool_op_log(uin=uin, FToolID=1026)

    # "查询零钱余额"
    @logger.catch
    @logging("查询零钱余额")
    def get_account_balances(self, uin):
        url = "http://testaccount.wxp.woa.com/useraccount/tool/get_account_balances"
        data = {"FToolID": 3, "cft_uin": uin, "t": int(format(int(time.time() * 1000)))}
        re = self.post_accpunt(url, data)
        return re

    #  查询 绑卡信息（绑卡序列号）
    @logger.catch
    @logging('查询 绑卡信息（绑卡序列号）')
    def query_wechat_pay_bindcard_info(self, uin):
        logger.info(f'{uin} 查询 绑卡信息（绑卡序列号）')

        url = "http://testaccount.wxp.woa.com/useraccount/tool/query_wechat_pay_bindcard_info"
        data = {
            "FToolID": 11,
            "FWechatUin": str(uin),
            "t": str(format(int(time.time() * 1000))),
        }
        re = self.post_accpunt(url, data)
        reData = re['data']['data']
        bankDataList = [{'bank_type': i['Fbank_type'], 'Fbind_serialno': i['Fbind_serialno']} for i in reData]
        return bankDataList


    #  解绑银行卡
    @logger.catch
    @logging('解绑银行卡')
    def unbind_bank_card(self, uin):
        logger.info(f'{uin} 解绑银行卡')
        url = "http://testaccount.wxp.woa.com/useraccount/tool/unbind_bank_card"
        data = {
            'FToolID': 6,
            'FWechatUin': str(uin),
            'FBankType': '',
            'FBindSerialno': '',
            'password': '135790',
            "t": str(format(int(time.time() * 1000))),
        }

        bankDataList = self.query_wechat_pay_bindcard_info(uin)
        for i in bankDataList:
            data['FBankType'] = i['bank_type']
            data['FBindSerialno'] = i['Fbind_serialno']
            self.post_accpunt(url, data)

        re = self.get_tool_op_log(uin=uin, FToolID=6, pagesize=len(bankDataList))
        return {'FToolName': '解绑单张银行卡', 'FOpStatus': '-'.join([item['FOpStatus'] for item in re])}

    @logger.catch
    @logging('账号恢复')
    def recoverUserAccount(self, uin,accid):
        logger.info(f'{uin,accid} 账号恢复')
        url = "http://xuat.wxp.woa.com/uataccountsvr/recoverUserAccount"
        data = {"uin": uin, "fitUin": accid, "userRegType": "3", "fqfBalance": "1000000", "payerUin": "0"}    # 有分付
        # data = {"uin": uin, "fitUin": accid, "userRegType": "3", "payerUin": "0"}    # 无分付
        re = self.post_uat(url, data)
        return re

    @logger.catch
    @logging('添加好友')
    def mmtools_addfriend(self, wxid01, wxid02):
        logger.info(f'{wxid01, wxid02} 添加好友')
        url = f"http://wxunitest.oa.com/mmtools/addfriend?username={wxid01}&friendname={wxid02}"
        re = self.mmtools_get(url)
        return re

    @logger.catch
    @logging('赠送亲属卡')
    def api_bind_honey_pay_card(self, uin01, uin02, wxid01, wxid02):
        self.mmtools_addfriend(wxid01, wxid02)
        logger.info(f'{uin01, uin02} 赠送亲属卡')
        url = "http://testaccount.wxp.woa.com/useraccount/tool/bind_honey_pay_card"
        data = {
            "FToolID": 21,
            "user_uin": uin01, # 赠卡方
            "payer_uin": uin02,  # 领卡方
            "card_type": 3,
            "credit_line": 3000*100,   # 亲属卡额度（分）
            "t": int(format(int(time.time() * 1000))),
        }
        re = self.post_accpunt(url, data)
        return re


    #  影印件实名认证
    @logger.catch
    @logging('影印件实名认证')
    def orc_auth(self, uin):
        logger.info(f'{uin} 影印件实名认证')
        url01 = "http://testaccount.wxp.woa.com/useraccount/tool/query_user_info"
        data01 = {
            'FToolID': 20,
            'FWechatUin': str(uin),
            "t": str(format(int(time.time() * 1000))),
        }
        re01 = self.post_accpunt(url01, data01)
        card = re01['data']['body']['creid_plain']

        url02 = 'http://testaccount.wxp.woa.com/useraccount/tool/query_user_info_by_ckv'
        data02 = {
            'FToolID': 1011,
            'FWechatUin': str(uin),
            'op_type': 0,
            "t": str(format(int(time.time() * 1000))),
        }
        re02 = self.post_accpunt(url02, data02)
        name = re02['data']['body']['true_name']
        if not name:
            return {'FToolName': '影印件实名认证', 'FOpStatus': '失败（用户姓名为空）'}

        # url03 = 'http://testaccount.wxp.woa.com/useraccount/tool/query_user_info_by_ckv'
        url03 = 'http://testaccount.wxp.woa.com/useraccount/tool/orc_auth'
        data03 = {
            'FToolID': 1031,
            'wechat_uin': str(uin),
            'ocr_state': 1,
            'cre_id': card,
            'true_name': name,
            "t": str(format(int(time.time() * 1000))),
        }
        self.post_accpunt(url03, data03)
        return self.get_tool_op_log(uin=uin, FToolID=1031)


    @logger.catch
    @logging("充值银行通")
    def post_api_yht_trade_in(self, accid, amount=1000):
        """充值银行通"""
        url = 'http://xapitest.wxp.woa.com/xautotest/busiapi/api/api_yht_trade_in'
        data = {'accid': accid, 'amount': amount}
        re = self.post_xapitest(url, data)
        return re

    @logger.catch
    @logging("开通分期")
    def post_api_account_manage(self, uin, accid):
        """开通分期"""
        url01 = "http://testaccount.wxp.woa.com/useraccount/tool/query_user_info"
        data01 = {
            'FToolID': 20,
            'FWechatUin': str(uin),
            "t": str(format(int(time.time() * 1000))),
        }
        re01 = self.post_accpunt(url01, data01)
        card = re01['data']['body']['creid_plain']

        self.post_api_modifying_userinfo(uin)   # 修改九要素
        url = 'http://xapitest.wxp.woa.com/xautotest/busiapi/api/api_account_manage'
        data = {'uin': accid, 'idcard_number': card}
        re = self.post_xapitest(url, data)

        try:
            if re['msg'] == 'ok' and re['data']['body']['data']['contract_no']:
                return {'FToolName': '开通分期', 'FOpStatus': '成功'}
            else:
                return {'FToolName': '开通分期', 'FOpStatus': '失败'}
        except:
            return {'FToolName': '开通分期', 'FOpStatus': '失败'}

    @logger.catch
    @logging("查询单个操作结果")
    def get_tool_op_log(self, uin, FToolID, pagesize=1):
        url = f'http://testaccount.wxp.woa.com/useraccount/tool/get_tool_op_log?page=1&pagesize={pagesize}&FToolID={FToolID}&op_status=&keywords={uin}&t={str(format(int(time.time() * 1000)))}'
        re = self.get_accpunt(url)
        data = re['data']['list']
        if len(data) == 0:
            return {'FToolName': '未查询到该操作', 'FOpStatus': '未知'}
        return data[0] if pagesize == 1 else data

    #  查询 用户号变更流水
    @logger.catch
    @logging('查询 用户号变更流水 仅获取今日的')
    def get_tool_op_logs(self):
        url = f"http://testaccount.wxp.woa.com/useraccount/tool/get_tool_op_log?page=1&pagesize=1000&t={str(format(int(time.time() * 1000)))}"
        re = self.get_accpunt(url)
        log_dict = {}
        data = re['data']['list']
        for i in data:
            if time.strftime("%Y-%m-%d", time.localtime(int(i['FCreateTime']))) != time.strftime("%Y-%m-%d", time.localtime(time.time())):
                # 判断操作流水是否属于今日
                break
            if not i['wechat_uin'] in log_dict.keys():
                log_dict[i['wechat_uin']] = []
            log_dict[i['wechat_uin']].append(f"{i['FToolName']}-{i['FOpStatus']}")

        # 将需要获取流水的工具名称添加到operationList
        operationList = ['开通零钱通1.5', '余额提额', '开通或关闭分付', '零钱通申购', '零钱通赎回', '开通银行通', '添加/更新分付白名单', '影印件实名']
        uinList = []
        with open("tapd.csv") as csvfile:
            csv_reader = csv.reader(csvfile)
            for row in csv_reader:
                if len(row) !=0 and row[1] in log_dict.keys():
                    loglst = []
                    for i in log_dict[row[1]]:
                        # 将难以查看结果的造号操作加入该判断列表中
                        if i.split("-")[0] in operationList:
                            loglst.append(i)
                    uinList.append(row[:4] + loglst)
                else:
                    uinList.append(row)

        with open("tapd.csv", "w+", newline="") as csvFile:
            csvFileWriter = csv.writer(csvFile)
            for item in uinList:
                csvFileWriter.writerow(item)
        return uinList

if __name__ == '__main__':
    # mchGroupId_data = Operation().get_mchGroupId(1165)['data']['mchAccountList']
    # mchdata_list = []
    # for item in mchGroupId_data:
    #     mchdata = Operation().get_mchAutoId(item['mchAutoId'])['data']
    #     mchdata_list.append(mchdata)
    # print(mchdata_list)

    data = [{'revokeType': 10, 'issueWorkOrderType': 0, 'issueWorkOrderId': 0, 'issueWorkOrderDesc': '', 'revokeReason': '扫码支付后台系统暂不支持limitpay，待后面补充实现，见群“【TAPD】【扫码支付】limit_pay禁用无法生效”[ID:1278]', 'impactScriptCount': 100, 'impactUnreadyScriptCount': 3}, {'revokeType': 10, 'issueWorkOrderType': 0, 'issueWorkOrderId': 0, 'issueWorkOrderDesc': '', 'revokeReason': '银行卡余额不足推荐其他支付方式的链路未通，见群“【扫码支付】银行扣款余额不足不会推荐零钱或零钱通”[ID:1349]', 'impactScriptCount': 59, 'impactUnreadyScriptCount': 0}, {'revokeType': 10, 'issueWorkOrderType': 0, 'issueWorkOrderId': 0, 'issueWorkOrderDesc': '', 'revokeReason': '扫码支付只支持零钱，零钱通，银行卡，亲属卡，见群“【TAPD】【扫码支付】默认支付方式设置失败讨论群”[ID:1387]', 'impactScriptCount': 38, 'impactUnreadyScriptCount': 2}, {'revokeType': 10, 'issueWorkOrderType': 0, 'issueWorkOrderId': 0, 'issueWorkOrderDesc': '', 'revokeReason': '扫码支付只支持零钱，零钱通，银行卡，亲属卡支付，见群“【TAPD】【扫码支付】默认支付方式设置失败讨论群”[ID:1375]', 'impactScriptCount': 38, 'impactUnreadyScriptCount': 0}, {'revokeType': 10, 'issueWorkOrderType': 0, 'issueWorkOrderId': 0, 'issueWorkOrderDesc': '', 'revokeReason': '扫码支付链路未通：支付中绑卡忘记密码，提示“商户：支付失败活取消支付-Cancel”https://tapd.woa.com/20426386/prong/stories/view/1020426386887839347[ID:1298]', 'impactScriptCount': 33, 'impactUnreadyScriptCount': 0}, {'revokeType': 10, 'issueWorkOrderType': 0, 'issueWorkOrderId': 0, 'issueWorkOrderDesc': '', 'revokeReason': '扫码支付暂不支持境外支付，见群“UAT*扫码支付产品”[ID:1344]', 'impactScriptCount': 32, 'impactUnreadyScriptCount': 0}, {'revokeType': 10, 'issueWorkOrderType': 0, 'issueWorkOrderId': 0, 'issueWorkOrderDesc': '', 'revokeReason': '群【没有上传身份证的前置条件无法触发上传身份证按钮讨论群】中确认剧本步骤“验证微信用户反馈的结果为上传身份证照”少挂了规则，为用例issue：https://git.woa.com/wxpay/system-usecase/issues/3246[ID:1270]', 'impactScriptCount': 30, 'impactUnreadyScriptCount': 0}, {'revokeType': 10, 'issueWorkOrderType': 0, 'issueWorkOrderId': 0, 'issueWorkOrderDesc': '', 'revokeReason': '扫码支付暂不支持境外支付，见群“UAT*扫码支付产品”[ID:1280]', 'impactScriptCount': 25, 'impactUnreadyScriptCount': 5}, {'revokeType': 10, 'issueWorkOrderType': 0, 'issueWorkOrderId': 0, 'issueWorkOrderDesc': '', 'revokeReason': '【扫码支付】确认失败信息，提示“商户：支付失败或取消支付 - Cancel”链路未通，https://tapd.woa.com/20426386/prong/stories/view/1020426386887879057[ID:1347]', 'impactScriptCount': 21, 'impactUnreadyScriptCount': 0}, {'revokeType': 10, 'issueWorkOrderType': 0, 'issueWorkOrderId': 0, 'issueWorkOrderDesc': '', 'revokeReason': '扫码支付暂不支持分付，见群“【TAPD】【扫码支付】默认支付方式设置失败讨论群”[ID:1372]', 'impactScriptCount': 19, 'impactUnreadyScriptCount': 0}, {'revokeType': 10, 'issueWorkOrderType': 0, 'issueWorkOrderId': 0, 'issueWorkOrderDesc': '', 'revokeReason': '扫码支付后台系统暂不支持limitpay，待后面补充实现，见群“【TAPD】【扫码支付】limit_pay禁用无法生效”[ID:1343]', 'impactScriptCount': 19, 'impactUnreadyScriptCount': 0}, {'revokeType': 10, 'issueWorkOrderType': 0, 'issueWorkOrderId': 0, 'issueWorkOrderDesc': '', 'revokeReason': '链路未通，提示“商户：支付失败或取消支付 - Cancel”，见群“【TAPD】【扫码支付】确认失败信息，提示“商户：支付失败或取消支付 - Cancel”讨论群”[ID:1351]', 'impactScriptCount': 15, 'impactUnreadyScriptCount': 0}, {'revokeType': 10, 'issueWorkOrderType': 0, 'issueWorkOrderId': 0, 'issueWorkOrderDesc': '', 'revokeReason': '除了付款码外欧盟协议相关的场景录入审查经验先不生成剧本，等bug修复后再建设[ID:774]', 'impactScriptCount': 13, 'impactUnreadyScriptCount': 0}, {'revokeType': 10, 'issueWorkOrderType': 0, 'issueWorkOrderId': 0, 'issueWorkOrderDesc': '', 'revokeReason': '链路未通，提示“商户：支付失败或取消支付 - Cancel”，见群“【TAPD】【扫码支付】确认失败信息，提示“商户：支付失败或取消支付 - Cancel”讨论群”[ID:1350]', 'impactScriptCount': 12, 'impactUnreadyScriptCount': 0}, {'revokeType': 10, 'issueWorkOrderType': 0, 'issueWorkOrderId': 0, 'issueWorkOrderDesc': '', 'revokeReason': '扫码支付暂不支持境外支付，见群“UAT*扫码支付产品”[ID:1277]', 'impactScriptCount': 11, 'impactUnreadyScriptCount': 0}, {'revokeType': 10, 'issueWorkOrderType': 0, 'issueWorkOrderId': 0, 'issueWorkOrderDesc': '', 'revokeReason': '群：商户应用ID指定的商户禁止微信用户使用xxx交易咨询，目前无法构造appid禁用xx支付方式[ID:1388]', 'impactScriptCount': 11, 'impactUnreadyScriptCount': 11}, {'revokeType': 10, 'issueWorkOrderType': 0, 'issueWorkOrderId': 0, 'issueWorkOrderDesc': '', 'revokeReason': '外卡支付授权付款时已弹出手续费弹窗场景暂无法测试，已提可测api需求，tapd链接：https://tapd.woa.com/wechatPay_UAT/prong/stories/view/1020426386887413595?jump_count=1[ID:1457]', 'impactScriptCount': 10, 'impactUnreadyScriptCount': 0}, {'revokeType': 10, 'issueWorkOrderType': 0, 'issueWorkOrderId': 0, 'issueWorkOrderDesc': '', 'revokeReason': '扫码支付暂不支持limitpay，见群“【TAPD】【扫码支付】limit_pay禁用无法生效”[ID:1378]', 'impactScriptCount': 10, 'impactUnreadyScriptCount': 0}, {'revokeType': 10, 'issueWorkOrderType': 0, 'issueWorkOrderId': 0, 'issueWorkOrderDesc': '', 'revokeReason': '【扫码支付】后台实现存在问题[ID:1464]', 'impactScriptCount': 10, 'impactUnreadyScriptCount': 3}, {'revokeType': 10, 'issueWorkOrderType': 0, 'issueWorkOrderId': 0, 'issueWorkOrderDesc': '', 'revokeReason': '扫码支付，修改预留手机号界面信息银行手机号信息未显示，https://tapd.woa.com/20426386/prong/stories/view/1020426386887762831[ID:1384]', 'impactScriptCount': 9, 'impactUnreadyScriptCount': 0}, {'revokeType': 10, 'issueWorkOrderType': 0, 'issueWorkOrderId': 0, 'issueWorkOrderDesc': '', 'revokeReason': '扫码支付暂不支持分付，见群“【TAPD】【扫码支付】默认支付方式设置失败讨论群”[ID:1374]', 'impactScriptCount': 9, 'impactUnreadyScriptCount': 0}, {'revokeType': 10, 'issueWorkOrderType': 0, 'issueWorkOrderId': 0, 'issueWorkOrderDesc': '', 'revokeReason': '扫码支付暂不支持修改预留手机号：https://tapd.woa.com/20426386/prong/stories/view/1020426386114825884[ID:1430]', 'impactScriptCount': 7, 'impactUnreadyScriptCount': 0}, {'revokeType': 10, 'issueWorkOrderType': 0, 'issueWorkOrderId': 0, 'issueWorkOrderDesc': '', 'revokeReason': '扫码支付，暂不支持分期，https://tapd.woa.com/20426386/prong/stories/view/1020426386000027403[ID:1369]', 'impactScriptCount': 7, 'impactUnreadyScriptCount': 0}, {'revokeType': 10, 'issueWorkOrderType': 0, 'issueWorkOrderId': 0, 'issueWorkOrderDesc': '', 'revokeReason': '扫码支付暂不支持limitpay，见群“【TAPD】【扫码支付】limit_pay禁用无法生效”[ID:1380]', 'impactScriptCount': 7, 'impactUnreadyScriptCount': 4}, {'revokeType': 10, 'issueWorkOrderType': 0, 'issueWorkOrderId': 0, 'issueWorkOrderDesc': '', 'revokeReason': '链路未通，提示“商户：支付失败或取消支付 - Cancel”，见群“【TAPD】【扫码支付】确认失败信息，提示“商户：支付失败或取消支付 - Cancel”讨论群[ID:1393]', 'impactScriptCount': 7, 'impactUnreadyScriptCount': 0}, {'revokeType': 10, 'issueWorkOrderType': 0, 'issueWorkOrderId': 0, 'issueWorkOrderDesc': '', 'revokeReason': '该微信用户提交的人脸和系统中记录的人脸是否一致:否后续用例有需要人脸验证成功，用例问题，改用例https://git.woa.com/wxpay/system-usecase/issues/3290[ID:1433]', 'impactScriptCount': 6, 'impactUnreadyScriptCount': 2}, {'revokeType': 10, 'issueWorkOrderType': 0, 'issueWorkOrderId': 0, 'issueWorkOrderDesc': '', 'revokeReason': '存在bug：https://tapd.woa.com/uat_issue_track/bugtrace/bugs/view?bug_id=1020423088111874509青少年限额场景中优惠拦截测试出的效果和产品的预期不符bug单[ID:617]', 'impactScriptCount': 6, 'impactUnreadyScriptCount': 3}, {'revokeType': 10, 'issueWorkOrderType': 0, 'issueWorkOrderId': 0, 'issueWorkOrderDesc': '', 'revokeReason': '扫码支付暂不支持境外支付，见群“UAT*扫码支付产品”[ID:1377]', 'impactScriptCount': 5, 'impactUnreadyScriptCount': 1}, {'revokeType': 10, 'issueWorkOrderType': 0, 'issueWorkOrderId': 0, 'issueWorkOrderDesc': '', 'revokeReason': '链路未通，提示“商户：支付失败或取消支付 - Cancel”，见群“【TAPD】【扫码支付】确认失败信息，提示“商户：支付失败或取消支付 - Cancel”讨论群[ID:1363]', 'impactScriptCount': 5, 'impactUnreadyScriptCount': 0}, {'revokeType': 10, 'issueWorkOrderType': 0, 'issueWorkOrderId': 0, 'issueWorkOrderDesc': '', 'revokeReason': '扫码支付暂不支持limitpay，见群“【TAPD】【扫码支付】limit_pay禁用无法生效”[ID:1376]', 'impactScriptCount': 4, 'impactUnreadyScriptCount': 0}, {'revokeType': 10, 'issueWorkOrderType': 0, 'issueWorkOrderId': 0, 'issueWorkOrderDesc': '', 'revokeReason': '零钱+二类卡日限额可测api实现不符合预期，已向fit提需求，见群“UAT-271185:问题：零钱根据最低待支付金额计算规则的计算结果-零钱+用户的二类卡日剩余额度规”[ID:1267]', 'impactScriptCount': 4, 'impactUnreadyScriptCount': 2}, {'revokeType': 10, 'issueWorkOrderType': 0, 'issueWorkOrderId': 0, 'issueWorkOrderDesc': '', 'revokeReason': '扫码支付暂不支持分付，见群“【TAPD】【扫码支付】默认支付方式设置失败讨论群”[ID:1395]', 'impactScriptCount': 4, 'impactUnreadyScriptCount': 2}, {'revokeType': 10, 'issueWorkOrderType': 0, 'issueWorkOrderId': 0, 'issueWorkOrderDesc': '', 'revokeReason': '完整注册未实名用户，UAT系统中未显示证件号，启用数字证书需填写身份证号，https://tapd.woa.com/20426386/prong/stories/view/1020426386114944108[ID:1463]', 'impactScriptCount': 4, 'impactUnreadyScriptCount': 0}, {'revokeType': 10, 'issueWorkOrderType': 0, 'issueWorkOrderId': 0, 'issueWorkOrderDesc': '', 'revokeReason': '【扫码支付】支付失败错误码未配置，支付失败只提示“订单支付失败，请确认”[ID:1461]', 'impactScriptCount': 3, 'impactUnreadyScriptCount': 0}, {'revokeType': 10, 'issueWorkOrderType': 0, 'issueWorkOrderId': 0, 'issueWorkOrderDesc': '', 'revokeReason': '同实名证件的微信支付账户的日累计支付金额+零钱根据最低待支付金额计算规则的计算结果是否>10000元:否、订单原价人民币金额计算规则的结果是否为大于20000元:是  特征冲突,tapd:https://tapd.woa.com/wechatPay_UAT/prong/stories/view/1020426386114876546?jump_count=1[ID:1471]', 'impactScriptCount': 3, 'impactUnreadyScriptCount': 0}, {'revokeType': 10, 'issueWorkOrderType': 0, 'issueWorkOrderId': 0, 'issueWorkOrderDesc': '', 'revokeReason': '目前uat用例已经同步，但是客户端需求并未同步，无法进行测试，相关脚本需要下线，已和rosen确认 tapd: https://tapd.woa.com/20423088/bugtrace/bugs/view?bug_id=1020423088112882727 群：UAT-206986[ID:796]', 'impactScriptCount': 3, 'impactUnreadyScriptCount': 0}, {'revokeType': 10, 'issueWorkOrderType': 0, 'issueWorkOrderId': 0, 'issueWorkOrderDesc': '', 'revokeReason': '扫码支付，暂不支持使用limitpay禁用[ID:1437]', 'impactScriptCount': 3, 'impactUnreadyScriptCount': 0}, {'revokeType': 10, 'issueWorkOrderType': 0, 'issueWorkOrderId': 0, 'issueWorkOrderDesc': '', 'revokeReason': '链路未通，提示“商户：支付失败或取消支付 - Cancel”，见群“【TAPD】【扫码支付】确认失败信息，提示“商户：支付失败或取消支付 - Cancel”讨论群[ID:1417]', 'impactScriptCount': 3, 'impactUnreadyScriptCount': 0}, {'revokeType': 10, 'issueWorkOrderType': 0, 'issueWorkOrderId': 0, 'issueWorkOrderDesc': '', 'revokeReason': '【扫码支付】支付失败错误码未配置，支付失败只提示“订单支付失败，请确认”[ID:1460]', 'impactScriptCount': 2, 'impactUnreadyScriptCount': 0}, {'revokeType': 10, 'issueWorkOrderType': 0, 'issueWorkOrderId': 0, 'issueWorkOrderDesc': '', 'revokeReason': '零钱根据最低待支付金额计算规则的计算结果-零钱提额用户的二类卡支付单笔限额规则的结果是否>0:是需要下单金额大于5W，使用浦发银行卡命中行业限额，规则待确认；tapd链接：https://tapd.woa.com/wechatPay_UAT/prong/stories/view/1020426386887171481?jump_count=1[ID:1459]', 'impactScriptCount': 2, 'impactUnreadyScriptCount': 0}, {'revokeType': 10, 'issueWorkOrderType': 0, 'issueWorkOrderId': 0, 'issueWorkOrderDesc': '', 'revokeReason': '收款请求信息.收款下单凭证指定的交易的付款用户是否与微信用户一致:否可测api实现不符合要求，要重新实现，待排期，群“105278”[ID:783]', 'impactScriptCount': 2, 'impactUnreadyScriptCount': 0}, {'revokeType': 10, 'issueWorkOrderType': 0, 'issueWorkOrderId': 0, 'issueWorkOrderDesc': '', 'revokeReason': '已绑定10张卡的用户再次添加新卡未进行拦截，后台bug待修复，见群“【TAPD】【扫码支付】已绑定10张卡的用户再次添加新卡未进行拦截讨论群”[ID:1428]', 'impactScriptCount': 2, 'impactUnreadyScriptCount': 0}, {'revokeType': 10, 'issueWorkOrderType': 0, 'issueWorkOrderId': 0, 'issueWorkOrderDesc': '', 'revokeReason': '【【扫码支付】limit_pay禁用无法生效】\nhttps://tapd.woa.com/wechatPay_UAT/prong/stories/view/1020426386887658775[ID:1367]', 'impactScriptCount': 2, 'impactUnreadyScriptCount': 0}, {'revokeType': 10, 'issueWorkOrderType': 0, 'issueWorkOrderId': 0, 'issueWorkOrderDesc': '', 'revokeReason': '扫码支付暂不支持分付，见群“【TAPD】【扫码支付】默认支付方式设置失败讨论群”[ID:1385]', 'impactScriptCount': 2, 'impactUnreadyScriptCount': 1}, {'revokeType': 10, 'issueWorkOrderType': 0, 'issueWorkOrderId': 0, 'issueWorkOrderDesc': '', 'revokeReason': '链路未通，提示“商户：支付失败或取消支付 - Cancel”，见群“【TAPD】【扫码支付】确认失败信息，提示“商户：支付失败或取消支付 - Cancel”讨论群[ID:1421]', 'impactScriptCount': 2, 'impactUnreadyScriptCount': 0}, {'revokeType': 10, 'issueWorkOrderType': 0, 'issueWorkOrderId': 0, 'issueWorkOrderDesc': '', 'revokeReason': '链路未通，提示“商户：支付失败或取消支付 - Cancel”，见群“【TAPD】【扫码支付】确认失败信息，提示“商户：支付失败或取消支付 - Cancel”讨论群[ID:1414]', 'impactScriptCount': 2, 'impactUnreadyScriptCount': 0}, {'revokeType': 10, 'issueWorkOrderType': 0, 'issueWorkOrderId': 0, 'issueWorkOrderDesc': '', 'revokeReason': '扫码支付链路未通，群“【TAPD】【扫码支付】确认失败信息，提示“商户：支付失败或取消支付 - Cancel”讨论群”[ID:1348]', 'impactScriptCount': 2, 'impactUnreadyScriptCount': 0}, {'revokeType': 10, 'issueWorkOrderType': 0, 'issueWorkOrderId': 0, 'issueWorkOrderDesc': '', 'revokeReason': '链路未通，提示“商户：支付失败或取消支付 - Cancel”，见群“【TAPD】【扫码支付】确认失败信息，提示“商户：支付失败或取消支付 - Cancel”讨论群[ID:1361]', 'impactScriptCount': 2, 'impactUnreadyScriptCount': 0}, {'revokeType': 10, 'issueWorkOrderType': 0, 'issueWorkOrderId': 0, 'issueWorkOrderDesc': '', 'revokeReason': '除了付款码外欧盟协议相关的场景录入审查经验先不生成剧本，等bug修复后再建设[ID:798]', 'impactScriptCount': 2, 'impactUnreadyScriptCount': 0}, {'revokeType': 10, 'issueWorkOrderType': 0, 'issueWorkOrderId': 0, 'issueWorkOrderDesc': '', 'revokeReason': '群249945中讨论步骤“验证WeChatPayHK系统反馈的结果为成功”香港钱包支付流程还没通[ID:1248]', 'impactScriptCount': 2, 'impactUnreadyScriptCount': 2}, {'revokeType': 10, 'issueWorkOrderType': 0, 'issueWorkOrderId': 0, 'issueWorkOrderDesc': '', 'revokeReason': '【扫码支付】暂不支持境外商户[ID:1537]', 'impactScriptCount': 2, 'impactUnreadyScriptCount': 0}, {'revokeType': 10, 'issueWorkOrderType': 0, 'issueWorkOrderId': 0, 'issueWorkOrderDesc': '', 'revokeReason': '扫码支付暂不支持设置触发中产品权限，待提可测api需求；https://tapd.woa.com/20426386/prong/stories/view/1020426386114786558#[ID:1396]', 'impactScriptCount': 2, 'impactUnreadyScriptCount': 0}, {'revokeType': 10, 'issueWorkOrderType': 0, 'issueWorkOrderId': 0, 'issueWorkOrderDesc': '', 'revokeReason': '【扫码支付】风控拦截规则的结果是否为需要微信用户通过客服系统解除交易限制:是。功能未实现[ID:1465]', 'impactScriptCount': 1, 'impactUnreadyScriptCount': 0}, {'revokeType': 10, 'issueWorkOrderType': 0, 'issueWorkOrderId': 0, 'issueWorkOrderDesc': '', 'revokeReason': '先分配得用户组无法调试，需要领卡方与赠卡是好友关系， 赠卡方有昵称，赠卡方名称取值不大于等于10，目前造号平台中可用用户组暂无符，基线结束撤销脚本，未有结论[ID:888]', 'impactScriptCount': 1, 'impactUnreadyScriptCount': 0}, {'revokeType': 10, 'issueWorkOrderType': 0, 'issueWorkOrderId': 0, 'issueWorkOrderDesc': '', 'revokeReason': '存在bug：https://tapd.woa.com/uat_issue_track/bugtrace/bugs/view?bug_id=1020423088111874509青少年限额场景中优惠拦截测试出的效果和产品的预期不符bug单[ID:673]', 'impactScriptCount': 1, 'impactUnreadyScriptCount': 0}, {'revokeType': 10, 'issueWorkOrderType': 0, 'issueWorkOrderId': 0, 'issueWorkOrderDesc': '', 'revokeReason': '扫码支付暂不支持limitpay，见群“【TAPD】【扫码支付】limit_pay禁用无法生效”[ID:1381]', 'impactScriptCount': 1, 'impactUnreadyScriptCount': 0}, {'revokeType': 10, 'issueWorkOrderType': 0, 'issueWorkOrderId': 0, 'issueWorkOrderDesc': '', 'revokeReason': '链路未通，提示“商户：支付失败或取消支付 - Cancel”，见群“【TAPD】【扫码支付】确认失败信息，提示“商户：支付失败或取消支付 - Cancel”讨论群[ID:1394]', 'impactScriptCount': 1, 'impactUnreadyScriptCount': 0}, {'revokeType': 10, 'issueWorkOrderType': 0, 'issueWorkOrderId': 0, 'issueWorkOrderDesc': '', 'revokeReason': '链路未通，提示“商户：支付失败或取消支付 - Cancel”，见群“【TAPD】【扫码支付】确认失败信息，提示“商户：支付失败或取消支付 - Cancel”讨论群[ID:1360]', 'impactScriptCount': 1, 'impactUnreadyScriptCount': 0}, {'revokeType': 10, 'issueWorkOrderType': 0, 'issueWorkOrderId': 0, 'issueWorkOrderDesc': '', 'revokeReason': '链路未通，提示“商户：支付失败或取消支付 - Cancel”，见群“【TAPD】【扫码支付】确认失败信息，提示“商户：支付失败或取消支付 - Cancel”讨论群”[ID:1356]', 'impactScriptCount': 1, 'impactUnreadyScriptCount': 0}, {'revokeType': 10, 'issueWorkOrderType': 0, 'issueWorkOrderId': 0, 'issueWorkOrderDesc': '', 'revokeReason': '链路未通，提示“商户：支付失败或取消支付 - Cancel”，见群“【TAPD】【扫码支付】确认失败信息，提示“商户：支付失败或取消支付 - Cancel”讨论群[ID:1364]', 'impactScriptCount': 1, 'impactUnreadyScriptCount': 0}, {'revokeType': 10, 'issueWorkOrderType': 0, 'issueWorkOrderId': 0, 'issueWorkOrderDesc': '', 'revokeReason': '反馈为银行处理中状态（银行桩mock实现），后又扣款成功，无法及时清除mock，暂无法测试，见群“210308”[ID:584]', 'impactScriptCount': 1, 'impactUnreadyScriptCount': 0}, {'revokeType': 10, 'issueWorkOrderType': 0, 'issueWorkOrderId': 0, 'issueWorkOrderDesc': '', 'revokeReason': '【【扫码支付】limit_pay禁用无法生效】 https://tapd.woa.com/wechatPay_UAT/prong/stories/view/1020426386887658775[ID:1371]', 'impactScriptCount': 1, 'impactUnreadyScriptCount': 0}, {'revokeType': 10, 'issueWorkOrderType': 0, 'issueWorkOrderId': 0, 'issueWorkOrderDesc': '', 'revokeReason': '零钱根据最低待支付金额计算规则的计算结果-零钱提额用户的二类卡支付单笔限额规则的结果是否>0:是需要下单金额大于5W，使用浦发银行卡命中行业限额，规则待确认；tapd链接：https://tapd.woa.com/wechatPay_UAT/prong/stories/view/1020426386887171481?jump_count=1[ID:1472]', 'impactScriptCount': 1, 'impactUnreadyScriptCount': 0}, {'revokeType': 10, 'issueWorkOrderType': 0, 'issueWorkOrderId': 0, 'issueWorkOrderDesc': '', 'revokeReason': '群UAT-217685: 确认该规则不应该展开,无法调试的脚本进行撤销[ID:727]', 'impactScriptCount': 1, 'impactUnreadyScriptCount': 1}, {'revokeType': 10, 'issueWorkOrderType': 0, 'issueWorkOrderId': 0, 'issueWorkOrderDesc': '', 'revokeReason': '因为分付在新版本中按照部门要求上线了httpdns功能，即dns解析走专门服务，不会走本地的dns配置\n这导致在hosts文件中指定域名到993 nginx vip， 无法使h5请求打到993环境[ID:1452]', 'impactScriptCount': 1, 'impactUnreadyScriptCount': 0}, {'revokeType': 10, 'issueWorkOrderType': 0, 'issueWorkOrderId': 0, 'issueWorkOrderDesc': '', 'revokeReason': '链路未通，提示“商户：支付失败或取消支付 - Cancel”，见群“【TAPD】【扫码支付】确认失败信息，提示“商户：支付失败或取消支付 - Cancel”讨论群”[ID:1357]', 'impactScriptCount': 1, 'impactUnreadyScriptCount': 0}, {'revokeType': 10, 'issueWorkOrderType': 0, 'issueWorkOrderId': 0, 'issueWorkOrderDesc': '', 'revokeReason': '【扫码支付】实名认证成功会弹出系统繁忙[ID:1536]', 'impactScriptCount': 1, 'impactUnreadyScriptCount': 0}, {'revokeType': 10, 'issueWorkOrderType': 0, 'issueWorkOrderId': 0, 'issueWorkOrderDesc': '', 'revokeReason': '链路未通，提示“商户：支付失败或取消支付 - Cancel”，见群“【TAPD】【扫码支付】确认失败信息，提示“商户：支付失败或取消支付 - Cancel”讨论群[ID:1413]', 'impactScriptCount': 1, 'impactUnreadyScriptCount': 0}, {'revokeType': 10, 'issueWorkOrderType': 0, 'issueWorkOrderId': 0, 'issueWorkOrderDesc': '', 'revokeReason': '链路未通，提示“商户：支付失败或取消支付 - Cancel”，见群“【TAPD】【扫码支付】确认失败信息，提示“商户：支付失败或取消支付 - Cancel”讨论群[ID:1358]', 'impactScriptCount': 1, 'impactUnreadyScriptCount': 0}, {'revokeType': 10, 'issueWorkOrderType': 0, 'issueWorkOrderId': 0, 'issueWorkOrderDesc': '', 'revokeReason': '链路未通，提示“商户：支付失败或取消支付 - Cancel”，见群“【TAPD】【扫码支付】确认失败信息，提示“商户：支付失败或取消支付 - Cancel”讨论群[ID:1392]', 'impactScriptCount': 1, 'impactUnreadyScriptCount': 0}, {'revokeType': 10, 'issueWorkOrderType': 0, 'issueWorkOrderId': 0, 'issueWorkOrderDesc': '', 'revokeReason': '扫码支付中验证下单请求信息不合法脚本未调通，设置商户属性都不生效；https://tapd.woa.com/20426386/prong/stories/view/1020426386114786558[ID:1416]', 'impactScriptCount': 1, 'impactUnreadyScriptCount': 0}, {'revokeType': 10, 'issueWorkOrderType': 0, 'issueWorkOrderId': 0, 'issueWorkOrderDesc': '', 'revokeReason': '扫码支付中验证下单请求信息不合法脚本未调通，设置商户属性都不生效；https://tapd.woa.com/20426386/prong/stories/view/1020426386114786558[ID:1422]', 'impactScriptCount': 1, 'impactUnreadyScriptCount': 0}, {'revokeType': 10, 'issueWorkOrderType': 0, 'issueWorkOrderId': 0, 'issueWorkOrderDesc': '', 'revokeReason': '扫码支付中验证下单请求信息不合法脚本未调通，设置商户属性都不生效；https://tapd.woa.com/20426386/prong/stories/view/1020426386114786558[ID:1425]', 'impactScriptCount': 1, 'impactUnreadyScriptCount': 0}, {'revokeType': 10, 'issueWorkOrderType': 0, 'issueWorkOrderId': 0, 'issueWorkOrderDesc': '', 'revokeReason': '服务商native支付验证下单请求信息不合法场景时生成订单就会拦截，无法下单拦截，需要虚拟商城工具修复，tapd链接：https://tapd.woa.com/wechatPay_UAT/prong/stories/view/1020426386114857994?jump_count=1[ID:1450]', 'impactScriptCount': 1, 'impactUnreadyScriptCount': 0}, {'revokeType': 10, 'issueWorkOrderType': 0, 'issueWorkOrderId': 0, 'issueWorkOrderDesc': '', 'revokeReason': '【扫码支付】未对扫码支付收银台的错误码进行细分，只会报500未知错误或系统繁忙[ID:1436]', 'impactScriptCount': 1, 'impactUnreadyScriptCount': 0}]

    print(data)